-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[10.x] Binding order is incorrect when using cursor paginate with multiple unions with a where #50884
[10.x] Binding order is incorrect when using cursor paginate with multiple unions with a where #50884
Conversation
I dunno - if the bindings were being duplicated this PR was already apparently broken? Why did the tests not show that? It shakes my confidence in merging 😅 |
Yeah I agree that that doesn't look too solid. |
I've given each builder its own variable name to make it a little bit easier to see what's going on. |
@thijsvdanker please mark this as ready if you need another review. |
I've added an Eloquent test that demonstrates the issue: 3e87617 |
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
When using
cursorPaginate
on a query that has multiple unions with their own where clause, the binding order is incorrect.This happens because:
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Database/Concerns/BuildsQueries.php#L436
adds the bindings for the cursor
where
to the end of the bindings and not in the position that they should be.The result is a query that binds the wrong values to the wrong parameters in the query.
This PR recreates the union bindings in the cursor paginate logic so that the cursor
where
binding is in the correct position.This PR is similar to #50810 but does not change the structure of the union binding to address the fear of a breaking change.
Instead it is only applied in the context of cursor pagination.